<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<link rel="stylesheet" href="../static/css/css.css">
<script src="../static/js/jquery-1.8.3.js"></script>
<body>
<script>
    function joinBargain(gsmBargainId) {
        $.ajax({
            type:"get",
            url:"/saveBargainRecord",
            data:{"gsmBargainId":gsmBargainId},
            dataType:"json",
            success:function (res) {
                if (res.code === 0) {
                    alert("success")
                } else {
                    alert("请先登录")
                    location.href = "http://auth.snow-mall.com?url=bargain.snow-mall.com";
                }
            }
        })
    }
    function lockMyRecord() {
        location.href = "/lockMyRecord";
    }
</script>
<ul>
    <li>
        <a th:if="${session.user != null}">欢迎, [[${session.user.usmName}]]</a>
        <a th:if="${session.user == null}" href="http://auth.snow-mall.com">你好，请登录</a>
    </li>
    <li>
        <a th:if="${session.user == null}" href="http://auth.snow-mall.com/register.html" class="li_2">免费注册</a>
    </li>
    <li>
        <a th:if="${session.user != null}" href="http://auth.snow-mall.com/loguot.html" class="li_2">立即退出</a>
    </li>
</ul>
<input th:if="${session.user != null}" type="button" value="查看我参与的砍价活动" onclick="lockMyRecord()">
<table>
    <tr>
        <td>活动名称</td>
        <td>商品名称</td>
        <td>商品展示</td>
        <td>商品原价</td>
        <td>限购数量</td>
        <td>活动时间</td>
        <td>活动描述</td>
        <td>操作</td>
    </tr>
    <tr th:each="li:${list.list}">
        <td th:text="${li.gsmBargainName}"></td>
        <td th:text="${li.psmName}"></td>
        <td>
            <img th:src="${li.psmImg}" alt="" style="width: 100px ; height: 100px">
        </td>
        <td th:text="${li.psmPrice}"></td>
        <td th:text="${li.gsmBargainLimitCount}"></td>
        <td th:text="${#dates.format(li.gsmBargainStartTime,'yyyy-MM-dd HH:mm:ss')}+ '     至     ' + ${#dates.format(li.gsmBargainEndTime,'yyyy-MM-dd HH:mm:ss')}" ></td>
        <td th:text="${li.gsmBargainShare}"></td>
        <td>
            <input type="button" value="参与砍价" th:onclick="|joinBargain(${li.gsmBargainId})|">
        </td>
    </tr>
</table>
</body>
</html>
